functionDirectory = cd('..');
filenames = {'data_raw\6SH20.csv','data_raw\6SM20.csv','data_raw\6SU20.csv','data_raw\6SZ20.csv','data_raw\6SH21.csv'};
tosavenames = {'output\FirstWorkspace6SH20','output\SecondWorkspace6SM20','output\ThirdWorkspace6SU20','output\FourthWorkspace6SZ20','output\FifthWorkspace6SH21',};
loop = 1;
while(loop<5)

loop = loop + 1;
filename = filenames{1,loop};

delimiter = ',';
startRow = 2;

%% Format for each line of text:
%   column3: datetimes (%{MM/dd/yyyy HH:mm:ss:SSS}D)
%	column5: datetimes (%{MM/dd/yyyy HH:mm:ss:SSS}D)
%   column7: double (%f)
%	column8: double (%f)
%   column10: double (%f)
%	column11: double (%f)
%   column14: double (%f)
%	column15: double (%f)
% For more information, see the TEXTSCAN documentation.
%formatSpec = '%*s%*s%{MM/dd/yyyy HH:mm:ss:SSS}D%*s%{MM/dd/yyyy HH:mm:ss:SSS}D%*s%f%f%*s%f%f%*s%*s%f%f%[^\n\r]';
formatSpec = '%*s%*s%*s%*s%{MM/dd/yyyy HH:mm:ss.SSS}D%*s%f32%u32%*s%f32%u32%*s%*s%f32%u32%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');

%% Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');

%% Close the text file.
fclose(fileID);

%% Post processing for unimportable data.
% No unimportable data rules were applied during the import, so no post
% processing code is included. To generate code which works for
% unimportable data, select unimportable cells in a file and regenerate the
% script.

%% Create output variable
ESU1820180801 = table(dataArray{1:end-1}, 'VariableNames', {'MarketMessageoriginalTimestamp','BestBidOfferMessagebidPrice','BestBidOfferMessagebidSize','BestBidOfferMessageofferPrice','BestBidOfferMessageofferSize','TradeMessageprice','TradeMessagesize'});

% For code requiring serial dates (datenum) instead of datetime, uncomment
% the following line(s) below to return the imported dates as datenum(s).

%% Clear temporary variables
clearvars filename delimiter startRow formatSpec fileID dataArray ans;

%%Processing
a2 = datetime(ESU1820180801{:,1},'TimeZone','UTC');
a2.TimeZone = 'America/New_York';
t2 = datenum(a2);

ESU1820180801{:,2} = round(ESU1820180801{:,2}*10000);
ESU1820180801{:,4} = round(ESU1820180801{:,4}*10000);
ESU1820180801{:,6} = round(ESU1820180801{:,6}*10000);
save(tosavenames{1,loop},ESU1820180801,'-v7.3')
end
cd(functionDirectory);
